package com.kavysoft.prueba;

import java.util.ArrayList;

import android.view.View;
import android.view.View.OnClickListener;

public class ButtonClick implements OnClickListener{
    int posicion;
    ArrayList<ItemGrid> data = new ArrayList<ItemGrid>();
    ImageAdapter adapter;
    MainActivity main;
    String message;
    
	public ButtonClick(ArrayList<ItemGrid> data, int position, ImageAdapter adapter, MainActivity main,String message) {
		this.data = data;
		this.posicion = position;
		this.adapter = adapter;
		this.main = main;
		this.message = message;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		data.get(posicion).setSw(!data.get(posicion).getSw());
		adapter.notifyDataSetChanged();
		int codigo = Integer.parseInt(message);
		
		if(data.get(posicion).getSw()){
			main.clientMSG.sendMessage(String.valueOf(codigo + 1));
		}else{
			main.clientMSG.sendMessage(String.valueOf(codigo));
			
		}
		
		
	}

}
